www.gusucode.com > 茶都拼客网全功能版 8 > 茶都拼客网全功能版 8.8源码程序/teasdxmccom/茶都拼客网V8.8(全功能,无限制,完全开源)/admin/Ku_Data.asp

    <!--#include file="../Ku_inc/Ku_sql.asp"-->
<!--#include file="../Ku_inc/Ku_config.asp"-->
<!--#include file="Ku_conn.asp"-->
<!--#include file="../Ku_inc/Ku_md5.asp"-->
<!--#include file="../Ku_inc/inc.asp"-->
<!-- #include file="Session.asp"-->


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><%=webname%>-数据库管理</title>
<link href="include/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
input{
	height:22px;
	border:1px solid #BEBEBE;
	background-color:#FFF;
	padding-top: 2px;
	padding-right: 8px;
	padding-bottom: 0pt;
	padding-left: 3px;
}
-->
</style>

</head>
<body>
<script>
<!--
 function del_check()
 {
    if(confirm("确定删除吗?"))
        return true;
    else
       return false;
 } 
-->
</script>
<div class="div_3"></div>
<table width="100%" border="0">
    <tr>
      <td>
  <%

 
'**************************************************
'函数名:IsObjInstalled
'作  用:检查组件是否已经安装
'参  数:strClassString ----组件名
'返回值:True  ----已经安装
'       False ----没有安装
'**************************************************
Function IsObjInstalled(strClassString)
	On Error Resume Next
	IsObjInstalled = False
	Err = 0
	Dim xTestObj
	Set xTestObj = Server.CreateObject(strClassString)
	If 0 = Err Then IsObjInstalled = True
	Set xTestObj = Nothing
	Err = 0
End Function


function deletefile(filename)
    if filename<>"" then
      set fso=server.CreateObject("scripting.FileSystemObject")
      if fso.FileExists(filename) then
        fso.DeleteFile filename
      else
	    response.Write ""
      end if
	  set fso=nothing
    end if
end function 

''------删除备份文件
if request("action")="del" then
   filename=server.MapPath(request("filename"))
   deletefile(filename)
   response.Redirect("ku_data.asp")
end if

'RootUrl="http://"&Request.ServerVariables("server_name")&Request.ServerVariables("path_info")
'RootUrl="http://"&Request.ServerVariables("server_name")
response.Write RootUrl
Sub BackupData()
'	On error resume next
	Dim FileConnStr, Fileconn, B_DBpath, B_BKpath, B_FileName
	
	B_DBpath = Request.Form("B_DBpath")
	B_DBpath = Server.Mappath(B_DBpath)
	B_BKpath = Request.Form("B_BKpath")
	B_BKpath = Server.Mappath(B_BKpath)
	B_FileName = Request.Form("B_FileName")

	FileConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & B_DBpath
	Set Fileconn = Server.CreateObject("ADODB.Connection")
	Fileconn.open FileConnStr

		Set Fileconn = Nothing

	
	Set Fso = Server.Createobject("scripting.FileSystemObject")

	If Fso.fileexists(B_DBpath) Then
		If CheckDir(B_BKpath) = True Then
			Fso.copyfile B_DBpath,B_BKpath& "\"& B_FileName
		Else
			MakeNewsDir(B_BKpath)
			Fso.copyfile B_DBpath,B_BKpath& "\"& B_FileName
		End If
		response.Write("备份数据库成功,您备份的数据库路径为" & B_BKpath & "\"& B_FileName &"")
	Else
		response.Write("找不到您所需要备份的文件。。")
	End if
End Sub
'------------------检查某一目录是否存在-------------------
Function CheckDir(FolderPath)
'	folderpath=Server.MapPath(".")&"\"&folderpath
    Set fso1 = CreateObject("Scripting.FileSystemObject")
    If fso1.FolderExists(FolderPath) then
       '存在
       CheckDir = True
    Else
       '不存在
       CheckDir = False
    End if
    Set fso1 = Nothing
End Function

'-------------根据指定名称生成目录-----------------------
Function MakeNewsDir(foldername)
	dim f
    Set fso1 = CreateObject("Scripting.FileSystemObject")
        Set f = fso1.CreateFolder(foldername)
        MakeNewsDir = True
    Set fso1 = nothing
End Function

'=====================压缩参数=========================
Function CompressData()
	Dim fso, Engine, strDBPath, JET_3X, dbPath
	dbPath = Trim(Request.Form("Y_DBpath"))
	dbPath = Server.Mappath(dbPath)
	strDBPath = left(dbPath,instrrev(DBPath,"\"))
	Set fso = CreateObject("Scripting.FileSystemObject")
	If fso.FileExists(dbPath) Then
		fso.CopyFile dbpath,strDBPath & "temp.mdb"
		Set Engine = CreateObject("JRO.JetEngine")

		Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb", _
		"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb"

		fso.CopyFile strDBPath & "temp1.mdb",dbpath
		fso.DeleteFile(strDBPath & "temp.mdb")
		fso.DeleteFile(strDBPath & "temp1.mdb")
		Set fso = Nothing
		Set Engine = Nothing

		response.Write("你的数据库"&dbpath&"已经压缩成功!")
	Else
		response.Write("数据库名称或路径不正确,请重新操作!")
	End If
End Function
%>
        <%
Dim fso,fso1, Action, H_Level 
'Action = GetSafeStr(Trim(Request("action")))
Action =Trim(Request("action"))
H_Level = Session("Sys_Level")

Select Case Action
Case "CompressData"		'压缩数据
	'If H_Level <> 3 Then
	'	response.Write("您的权限不够进行此操作!")
	'Else
		Call CompressData()
	'End If

Case "BackupData"		'备份数据
	'If H_Level <> 3 Then
	'	response.Write("您的权限不够进行此操作!")
	'Else
		Call BackupData()
	'End If
	
Case "RestoreData"		'恢复数据
	'If H_Level <> 3 Then
	'	response.Write("您的权限不够进行此操作!")
	'Else
		Dim H_DBpath, H_Backpath

		H_DBpath = request.form("H_DBpath")
		H_Backpath = request.form("H_Backpath")
	
		If H_DBpath = "" then
			response.Write("请输入您要恢复成的数据库全名!")
		Else
			H_DBpath = Server.Mappath(H_DBpath)
		End if
	
		H_Backpath = Server.Mappath(H_Backpath)
		
		Set Fso = Server.CreateObject("scripting.FileSystemObject")
		If fso.fileexists(H_Backpath) Then  					
			fso.copyfile H_Backpath,H_DBpath
			response.Write("成功恢复数据!")
		Else
			response.Write("备份目录下并无您的备份文件!")
		End If
	'End If
End Select

'====================恢复数据库=========================
'Call Header("数据库操作处理")
Call Content()
'Call Footer()

' 开始写入内容
Sub Content()
%>
        <%'====================恢复数据库=========================%>
        <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="25" class="td_title"><b><font color="#FF0000">数据库操作</font></b></td>
          </tr>
        </table>

        <%'====================备份数据库=========================%>
        <table width="100%" border="0" align="center" cellpadding="5"  cellspacing="1" bgcolor="#DDDDDD">
          <tr>
            <td width="713" bgcolor="#999999"><b style="color:#000000">备份数据 </b>(所有路径都是相对与程序空间根目录的相对路径)</td>
          </tr>
          <form method="post" action="ku_data.asp?action=BackupData">
            <tr>
              <td> 当前数据库路径(绝对路径):
                <input name="B_DBpath" type="text" id="B_DBpath" value="<%=db%>" size="60" class="button1" / readonly></td>
            </tr>
            <tr>
              <td height="25">备份数据库目录(绝对路径):
                <input name="B_BKpath" type="text" id="B_BKpath" value="../Databf" size="60" class="button1" / readonly></td>
            </tr>
            <tr>
              <td>备份数据库名称(填写名称):
                <input type="button" name="tjiao" value="加日期" onClick="B_FileName.value='<%=formatdatetime(now(),Vbshortdate)%><%=dataBak_name%>bf.sql'"/>
                <input name="B_FileName" type="text" id="B_FileName" value="<%=dataBak_name%>pinkebf.sql" size="35" class="button1" / readonly>
                <input name="submit2" type="submit" value="确定备份" class="button2" /></td>
            </tr>
            <tr>
              <td bgcolor="#FFFFFF">-----------------------------------------------------------------------------------------<br />
                <b>注意:</b>您可以用这个功能来备份您的法规数据,以保证您的数据安全!如备份目录不存在,程序将自动创建;如备份目录有该数据库文件,将覆盖,如没有,将自动创建。在上面填写本程序的数据库路径全名,本程序的默认数据库文件为“<%=data_path%>”,<font color="#FF0000">请不要用默认名称命名备份数据库。</font></td>
            </tr>
          </form>
        </table>
        <%'====================压缩数据库 =========================%>
        <table border="0"  cellspacing="1" cellpadding="3" align="center" width="100%">
          <form action="ku_data.asp?action=CompressData" method="post">
            <tr>
              <td><b>压缩系统数据 </b>(所有路径都是相对与程序空间根目录的相对路径)</td>
            </tr>
            <tr>
              <td>压缩数据库:
                <input name="Y_DBpath" type="text" id="Y_DBpath" value="<%=db%>" size="60" class="button1" / readonly>
                <input name="submit3" type="submit" value="开始压缩" class="button2" /></td>
            </tr>
            <tr>
              <td><b>注意:</b>输入数据库所在相对路径,并且输入数据库名称。(本系统采用 Access 2000 数据库)</td>
            </tr>
          </form>
          <form>
          </form>
        </table>
        <table border="0"  cellspacing="0" cellpadding="5" align="center" width="100%">
          <form action="ku_data.asp?action=CompressData" method="post">
            <tr>
              <td class="td_title"><div align="center"><span class="STYLE1">当前数据库文件大小:</span>
                <%
		If not IsObjInstalled("Scripting.FileSystemObject") Then
	           Response.Write "<b><font color=red>服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b>"
       Else
	    Set fso=Server.CreateObject("Scripting.FileSystemObject")
		    file_=db      ''当前数据库路径
           If fso.FileExists(file_) Then
              response.Write "找不到文件"
		   Else
		      set fz=fso.getfile(server.MapPath(file_))
			  response.Write FormatNumber(fz.size/1024,0)&"KB"
			  set fz=nothing
		   end if
		'   set fso=nothing
	   end if	
		
		%>
                </div></td>
            </tr>
          </form>
          <form>
          </form>
        </table>
        <table width="100%" border="0" align="center" cellpadding="3"  cellspacing="0" bgcolor="#CCCCCC">
          <form action="ku_data.asp?action=CompressData" method="post">
            <tr>
              <td>
                <table width="100%" border="0">
                  <tr>
                    <td width="180" class="td2">文件名</td>
                      <td width="91" class="td2">文件大小</td>
                      <td width="113" class="td2">备份日期</td>
                      <td width="44" class="td2">删除</td>
                  </tr>
                  <%
                  dataUP_dir="Databackup/"
   If not IsObjInstalled("Scripting.FileSystemObject") Then
	 Response.Write "<b><font color=red>服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b>"
   Else
     If fso.FolderExists(dataUP_dir&dataBak_path) Then
        response.Write "找不到备份文件夹"
	 Else
	   	Set theFolder=fso.GetFolder(server.MapPath("../"&dataUP_dir&dataBak_path))
		    response.Write "备份数据库文件夹占空间大小为:"&FormatNumber(theFolder.Size/1024/1024,5)&"MB"
	        For Each theFile In theFolder.Files   
  %>
                  <tr height="22">
                    <td bgcolor="#FFFFFF"><%=theFile.Name%></td>
                      <td bgcolor="#FFFFFF"><%=FormatNumber(theFile.Size/1024,0)%>KB</td>
                      <td bgcolor="#FFFFFF"><%=theFile.DateLastModified%></td>
                      <td bgcolor="#FFFFFF"><a href="?action=del&amp;filename=<%=server.URLEncode("../"&dataUP_dir&dataBak_path&theFile.Name)%>" onClick="return del_check();">删除</a></td>
                  </tr>
                  <%
   		   next
		   set theFolder=nothing
		   set fso=nothing
	  end if	   
  end if	
  %>
                </table></td>
            </tr>
          </form>
          <form>
          </form>
        </table>
        <p>&nbsp; </p>
      <%
End Sub
%></td>
    </tr>
  </table>
<!--#include file="Ku_bottom.asp" -->
</body>
</html>
<%


%>